﻿#ifndef HTTPSERVICE_H
#define HTTPSERVICE_H

#include <QObject>
#include <QWidget>
#include <QHttpServer>
#include "basecontroller.h"
#include <QMutex>

class HttpService : public QObject
{
    Q_OBJECT
public:
    /**
    * 获取单例实例
    * @return 返回单例实例
    */
    static HttpService& getInstance();
    /**
    * 删除单例实例
    */
    static void deleteInstance();

    void installController(BaseController *controller,QString path);
public:
    void start();
    void stop();
private:
    explicit HttpService(QObject *parent = nullptr);
    ~HttpService();

    static HttpService* instance;
    static QMutex mutex;

    QHttpServer httpServer;
    QVector<BaseController*> controllers;

};

#endif // HTTPSERVICE_H
